//
//  HttpTool.h
//  XV
//
//  Created by apple on 2019/03/11.
//  Copyright © 2019 XV. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void (^SuccessData)(id responseObject);

typedef void (^ErrorData)(NSError *error);

typedef void (^ProgressData)(NSProgress * progress);


@interface HttpTool : NSObject

+ (instancetype)sharedManager;

//设置请求头
-(void)setRequestHeader:(NSDictionary*)dicHeader;

/**
 *  设置请求超时时间
 *
 *  @param dTimeOut nTimeOut description
 */
-(void)SetRequestTimeOut:(double)dTimeOut;

/**
 *  取消请求
 */
-(void)CancelRequest;

//设置主url
-(void)setMainUrl:(NSString*)mainUrl;

//获取主url
-(NSString*)getMainUrl;


/**
 Get请求

 @param strUrl <#strUrl description#>
 @param dicParameters <#dicParameters description#>
 */
- (void)GetRequest:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;

//Get请求是否需要签名
- (void)GetRequest:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters isSign:(BOOL)isSign success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;

//Get请求是否返回原数据
- (void)GetRequest:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters isSign:(BOOL)isSign isReturnSrcData:(BOOL)isReturnSrcData success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;


/**
 Post请求

 @param strUrl <#strUrl description#>
 @param dicParameters <#dicParameters description#>
 @param ReqSuccess <#ReqSuccess description#>
 @param ReqFailure <#ReqFailure description#>
 */
- (void)PostRequest:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;

//Post请求是否需要签名
- (void)PostRequest:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters isSign:(BOOL)isSign success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;

//Post请求是否返回原数据
- (void)PostRequest:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters isSign:(BOOL)isSign isReturnSrcData:(BOOL)isReturnSrcData success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;


/**
 Delete请求

 @param strUrl <#strUrl description#>
 @param dicParameters <#dicParameters description#>
 @param ReqSuccess <#ReqSuccess description#>
 @param ReqFailure <#ReqFailure description#>
 */
- (void)DeleteRequest:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;


/**
 上传图片

 @param image 图片
 @param strUrl <#strUrl description#>
 @param dicParameters <#dicParameters description#>
 @param ReqSuccess <#ReqSuccess description#>
 @param ReqFailure <#ReqFailure description#>
 */
- (void)UploadImage:(UIImage *)image url:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;


/**
 上传文件

 @param filePath 本地文件路径
 @param formDataDict appendPartWithFileData数据
 [formData appendPartWithFileData:data
 name:@"upfile"
 fileName:@"image.jpg"
 mimeType:@"image/jpeg"];
 @param strUrl 上传文件的地址
 @param dicParameters <#dicParameters description#>
 @param uploadProgress 上传进度
 @param ReqSuccess <#ReqSuccess description#>
 @param ReqFailure <#ReqFailure description#>
 */
- (void)UploadFile:(NSString *)filePath formDataDict:(NSDictionary*)formDataDict url:(NSString *)strUrl Parameters:(NSDictionary *)dicParameters progress:(ProgressData)uploadProgress success:(SuccessData)ReqSuccess failure:(ErrorData)ReqFailure;


@end

